perm filename MAP.LST[HAL,HE] blob sn#192280 filedate 1975-12-16 generic text, type T, neo UTF8
	PALX 231	12/16/75  11:43:25	PAGE 1
	MAP PAL[HAL,HE]	PAGE 1 	

				COMMENT ⊗   VALID 00009 PAGES
				C REC  PAGE   DESCRIPTION
				C00001 00001
				C00002 00002	 This is a test program to try out some ideas about the
				C00004 00003	  Map definitions
				C00006 00004	  Common area
				C00008 00005	  COMMON, PINIT, TOSPC
				C00013 00006	  SWITCH
				C00015 00007	  DRIVER
				C00016 00008	  Area zero
				C00018 00009	.END
				C00019 ENDMK
					C⊗;
	PALX 231	12/16/75  11:43:25	PAGE 2
	MAP PAL[HAL,HE]	PAGE 2 	

				COMMENT ⊗ This is a test program to try out some ideas about the
				proper use of the glorious Panofsky map.  We will set up four maps,
				each of which shares locations 0 → 17777 and 120000 → 177777.  The
				locations 20000 → 30000 will be distinct for each of the four maps.
				Into each of these areas will be assembled a printing routine (which
				will identify which county it is in) and a call to each of the other
				county's map routines.  Calling an unreachable location will be done
				by this code:
				
					MOV #LNAME,-(SP)	;The link name of the routine
					JSR PC,SWITCH		;A routine in common space to do it all
				
				The link name is an pointer into the link table.  Each entry in that
				table is two words.  The second is the number of the appropriate
				county (0:3), and the first is the address in that county's scheme. 
				The switch routine will keep track of the stack and will set the
				return address to something in itself.  It will therefore also have
					to fix up the return.  ⊗
	PALX 231	12/16/75  11:43:25	PAGE 3
	MAP PAL[HAL,HE]	PAGE 3 	

					;  Map definitions
					
					;Page tables
		166000			PTAB0 = 166000		;100 words, 1 per page
		166200			PTAB1 = 166200		;100 words, 1 per page
		166400			PTAB2 = 166400		;100 words, 1 per page
		166600			PTAB3 = 166600		;100 words, 1 per page
					
					;Page table entries (each one for 2000 bytes)
		100000			WRINTO == 100000	;Page has been written into
		040000			ACCESD ==  40000	;Page has been accessed
		020000			WRPERM ==  20000	;Page may be written into
		010000			RDPERM ==  10000	;Page may be read from
		004000			UNIBIT ==   4000	;on => unibus only.  off => fastbus only
		003777			PHSPAG ==   3777	;high order address bits of physical page
					
					;Map space table
		167020			KISPCE = 167020		;Kernel I space
		167030			KDSPCE = 167030		;Kernel D space
		167022			SISPCE = 167022		;Supervisor I space
		167032			SDSPCE = 167032		;Supervisor D space
		167024			NISPCE = 167024		;Unused I space
		167034			NDSPCE = 167034		;Unused D space
		167026			UISPCE = 167026		;User I space
		167036			UDSPCE = 167036		;User D space
					
					;Map space table entries
		001400			PTABNO == 1400		;The page table (0:3) to use for this space
		000200			TRANSP ==  200		;1 => no mapping
		000176			MXVRPG ==  176		;Maximum page that may be referenced
					
					;Status registers
		167000			STATR0 = 167000		;Status register 0
		100000				MAPENB == 100000	;1 => enable mapping
					
					
	PALX 231	12/16/75  11:43:25	PAGE 4
	MAP PAL[HAL,HE]	PAGE 4 	

					;  Common area
					
					.INSRT HALHED[HAL,HE]
	PALX 231	12/16/75  11:43:25	PAGE 5
	HALHED PAL[HAL,HE]	PAGE 1 	

				COMMENT ⊗   VALID 00005 PAGES
				C REC  PAGE   DESCRIPTION
				C00001 00001
				C00002 00002	.SBTTL  Switches, absolute locations, registers, mark instructions
				C00006 00003	Routine calling and defining macros  ROUTINE, CALL, FP
				C00009 00004	Macros: TELL, INFO, XX, TT, PUTLOC
				C00011 00005	Separate assembly communication facility COMTAB
				C00016 ENDMK
					C⊗;
	PALX 231	12/16/75  11:43:25	PAGE 6
	HALHED PAL[HAL,HE]	PAGE 2 	Switches, absolute locations, registers, mark instructions

					.SBTTL  Switches, absolute locations, registers, mark instructions
					
					;This macro gives the switch SW a default value VAL
					       .MACRO STSW SW,VAL
					       .IFNDF SW
						SW == VAL   ;if do not have a value already, give it one
					       .ENDC
					       .ENDM
					
					
					
					; PROGRAM DEFINITIONS
					
					;  Refer to UNIBUS.BO[11,DOC] for all absolute location meanings
					
		000004			ERRTRP==4		;time out and error trap
		000010			ILGINS==10		;illegal instruction
		000104			CLKTRP==104		;clock trap
		000130			DACVEC==130		;DAC interrupt vector
		000134			ADCVEC==134		;ADC interrupt vector
		000200			ARMTRP==200		;Arm error interrupt vector
		130000			RUG=130000		;Restart of RUG
		130000			DDT=130000		;Restart of DDT
		177776			PS=177776		;processor status word
		170777			VITTS=170777		;Video Intensity Table Table Select
		171000			VIT=171000		;Video Intensity Table (400 words long)
		177560			KBIS=177560		;keyboard input status
		177562			KBIR=177562		;keyboard input register
		177564			KBOS=177564		;keyboard output status
		177566			KBOR=177566		;keyboard output register
		172544			CLKCNT=172544		;clock counter
		172542			CLKSET=172542		;clock set register
		172540			CLKS=172540		;clock status
					
		000500			STRT11=500		;starting address of program
		000150			IBUF==150		;start of input buffer from 11
		000160			OBUF==160		;start of output buffer to 11 
		157776			HCOR=157776		;highest useable word in core
		157776			OREG=HCOR		;put something here, 11TTY will print it on console
		157774			IREG=HCOR-2		;11TTY puts stuff here for console input
		157772			OUTSW=HCOR-4		;0 => your console; -1 => VT05
					
					;REGISTER DEFINITIONS
					
		000007			PC=%7			;program counter
		000006			SP=%6			;stack pointer
		000005			RF==%5			;Display pointer
		000005			R5=%5
		000004			R4=%4			;Saved across procedure calls
	PALX 231	12/16/75  11:43:25	PAGE 7
	HALHED PAL[HAL,HE]	PAGE 2.1 	Switches, absolute locations, registers, mark instructions

		000003			R3=%3			;Saved across procedure calls
		000002			R2=%2			;Saved across procedure calls
		000001			R1=%1			;temp
		000000			R0=%0			;temp
		000005			AC5==%5			;Temp Floating point register
		000004			AC4==%4			; "      "       "      "
		000003			AC3==%3			; "      "       "      "
		000002			AC2==%2			; "      "       "      "
		000001			AC1==%1			; "      "       "      "
		000000			AC0==%0			; "      "       "      "
					
					;MARK DEFINITIONS
		006400			MARK0 == 6400		;MARK 0
		006401			MARK1 == 6401		;MARK 1
		006402			MARK2 == 6402		;ETC.
		006403			MARK3 == 6403
		006404			MARK4 == 6404
		006405			MARK5 == 6405
					
	PALX 231	12/16/75  11:43:25	PAGE 8
	HALHED PAL[HAL,HE]	PAGE 3 	Switches, absolute locations, registers, mark instructions

					;Routine calling and defining macros  ROUTINE, CALL, FP
					;Coded by RHT 9/74.
					
					;This should be used at the start of routines which reference
					;	parameters off the RF stack.  It gives the parameters
					;	symbolic names for clarity of coding.
					;For example,
					;
					;	ROUTINE FOO,<A,B>
					;
					;Goes to
					;
					;	A==4
					;	B==2
					;FOO:
					
					       .MACRO ROUTINE ID,ARGS
					           .IFNB ARGS
						    NNNN==0
						       .IRP II,<ARGS>		;Raise NNNN to twice the number of args.
					                   NNNN==NNNN+2
						       .ENDM
						       .IRP II,<ARGS>		;Assign each arg NNNN and decrease same.
					                  .IFDF II
					                      .IF1 
					                           .ERROR Multiple definition for II
					                      .ENDC
					                  .ENDC
					                   II == NNNN
					                   NNNN == NNNN-2
						       .ENDM
						   .ENDC
					ID:
					       .ENDM
					
					;This is useful in calling rountines which reference parameters off
					;	the RF stack.  It sets up the stack properly, but does not
					;	save R0 or R1.
					
					       .MACRO CALL ID,ARGS
						MOV	RF,-(SP)	;Save RF
						NNNN == 6400		;This is a MARK 0 instruction
						   .IFNB ARGS
						       .IRP II,<ARGS>
							MOV	II,-(SP);Push an argument
							NNNN == NNNN+1	;Make NNNN the next MARK instruction.
						       .ENDM
						   .ENDC
						MOV	#NNNN,-(SP)	;Push the mark instruction.
	PALX 231	12/16/75  11:43:25	PAGE 9
	HALHED PAL[HAL,HE]	PAGE 3.1 	Switches, absolute locations, registers, mark instructions

						MOV	SP,RF		;Set up the display in RF.
						JSR	PC,ID		;Call the routine
					       .ENDM
					
					
					;This macro is a temporary method of defining floating point
					;constants. LABIL is the constant name and MSB and LSB its two
					;16 bit octal parts.
					
					       .MACRO FP  LABIL,MSB,LSB
						.MACRO  LABIL
						 	.WORD	MSB,LSB	
						.ENDM
					       .ENDM
					
	PALX 231	12/16/75  11:43:25	PAGE 10
	HALHED PAL[HAL,HE]	PAGE 4 	Switches, absolute locations, registers, mark instructions

					;Macros: TELL, INFO, XX, TT, PUTLOC
					
						.MACRO TELL VAR
							TELL2 VAR,\VAR
						.ENDM
					
						.MACRO TELL2 S,V
							.PRINT /S = /
							.PRINT /V
					/
						.ENDM
					
					        .MACRO .INFO STR,NUM
					                .PRINT /STR/
					                .PRINT /NUM
					/
					        .ENDM
					
					       .MACRO	XX SYM			;Just gives SYM the next number.
						   .IFDF SYM
						       .IF1
						       .ERROR You are using SYM in two ways!!!
						       .ENDC
						   .ENDC
						    SYM == II
						    II == II+2
					       .ENDM
					
					       .MACRO TT INX,VAL		;To store data at an offset from II
					        .=II+INX
					        VAL
					       .ENDM
					
					       .MACRO PUTLOC   ADR,VAL
					        II==.
					        .= ADR
					        VAL
					       .=II
					       .ENDM
	PALX 231	12/16/75  11:43:25	PAGE 11
	HALHED PAL[HAL,HE]	PAGE 5 	Switches, absolute locations, registers, mark instructions

					;Separate assembly communication facility COMTAB
					
				COMMENT  ⊗  All locations local to one assembly which need
					to be known to the others are listed here.  ⊗
					
		014000			COMTAB = 14000		;Communication table
		014100			INTRP == 14100		;Beginning of the interpeter code
		054000			PCODE = 54000		;Pseudo-code start address
		060000			ARMCOD = 60000		;Beginning of the arm code
					
					;The following is the COMTAB.  It has room for =32 labels.
		014000				II == COMTAB	
						XX LGETVAL	;Routine for searching graph structure
						   .IFDF LGETVAL
						       .IF1
						       .ERROR You are using LGETVAL in two ways!!!
						       .ENDC
						   .ENDC
		014000				    LGETVAL == II
		014002				    II == II+2
						XX LGETARG	;Finds place in environment for level-offset
						   .IFDF LGETARG
						       .IF1
						       .ERROR You are using LGETARG in two ways!!!
						       .ENDC
						   .ENDC
		014002				    LGETARG == II
		014004				    II == II+2
						XX LINVLDT	;Invalidates graph node
						   .IFDF LINVLDT
						       .IF1
						       .ERROR You are using LINVLDT in two ways!!!
						       .ENDC
						   .ENDC
		014004				    LINVLDT == II
		014006				    II == II+2
						XX LINTARM	;Arm initialization
						   .IFDF LINTARM
						       .IF1
						       .ERROR You are using LINTARM in two ways!!!
						       .ENDC
						   .ENDC
		014006				    LINTARM == II
		014010				    II == II+2
						XX LCENTER	;Center routine
						   .IFDF LCENTER
						       .IF1
						       .ERROR You are using LCENTER in two ways!!!
						       .ENDC
	PALX 231	12/16/75  11:43:25	PAGE 12
	HALHED PAL[HAL,HE]	PAGE 5.1 	Switches, absolute locations, registers, mark instructions

						   .ENDC
		014010				    LCENTER == II
		014012				    II == II+2
						XX LWHERE	;Where routine
						   .IFDF LWHERE
						       .IF1
						       .ERROR You are using LWHERE in two ways!!!
						       .ENDC
						   .ENDC
		014012				    LWHERE == II
		014014				    II == II+2
						XX LMOVE	;Move routine
						   .IFDF LMOVE
						       .IF1
						       .ERROR You are using LMOVE in two ways!!!
						       .ENDC
						   .ENDC
		014014				    LMOVE == II
		014016				    II == II+2
						XX LSQRTF	;Square root routine
						   .IFDF LSQRTF
						       .IF1
						       .ERROR You are using LSQRTF in two ways!!!
						       .ENDC
						   .ENDC
		014016				    LSQRTF == II
		014020				    II == II+2
						XX LFORCE	;Routine to calculate force
						   .IFDF LFORCE
						       .IF1
						       .ERROR You are using LFORCE in two ways!!!
						       .ENDC
						   .ENDC
		014020				    LFORCE == II
		014022				    II == II+2
						XX LERRPTR	;All error torques:  indirect table
						   .IFDF LERRPTR
						       .IF1
						       .ERROR You are using LERRPTR in two ways!!!
						       .ENDC
						   .ENDC
		014022				    LERRPTR == II
		014024				    II == II+2
						XX LTHPTR	;All theta:  joint angle indirect table
						   .IFDF LTHPTR
						       .IF1
						       .ERROR You are using LTHPTR in two ways!!!
						       .ENDC
						   .ENDC
	PALX 231	12/16/75  11:43:25	PAGE 13
	HALHED PAL[HAL,HE]	PAGE 5.2 	Switches, absolute locations, registers, mark instructions

		014024				    LTHPTR == II
		014026				    II == II+2
						XX LDVCPTR	;Device block ptrs for attached servos
						   .IFDF LDVCPTR
						       .IF1
						       .ERROR You are using LDVCPTR in two ways!!!
						       .ENDC
						   .ENDC
		014026				    LDVCPTR == II
		014030				    II == II+2
						XX LUPDATE	;Arm solution to go from joint angles to transform
						   .IFDF LUPDATE
						       .IF1
						       .ERROR You are using LUPDATE in two ways!!!
						       .ENDC
						   .ENDC
		014030				    LUPDATE == II
		014032				    II == II+2
					
				COMMENT ⊗
				If you want to define where, say, DRIVE is, you should do this:
					PUTLOC LDRIVE, DRIVE
				If you want to call, say, GETVAL, you should do this:
					JSR PC,@LGETVAL
					⊗
	PALX 231	12/16/75  11:43:25	PAGE 14
	K1DEF PAL[11,SYS]	PAGE 4.1 	Switches, absolute locations, registers, mark instructions

					.INSRT K1DEF.PAL[11,SYS]
	PALX 231	12/16/75  11:43:25	PAGE 15
	K1DEF PAL[11,SYS]	PAGE 1 	Switches, absolute locations, registers, mark instructions

				COMMENT ⊗   VALID 00005 PAGES
				C REC  PAGE   DESCRIPTION
				C00001 00001
				C00002 00002		USER PROCESS DESCRIPTOR BLOCK
				C00007 00003		EMT OPERATIONS
				C00009 00004		EXPLANATIONS OF THE SYSTEM CALLS
				C00018 00005	USRORG==14000
				C00019 ENDMK
					C⊗;
	PALX 231	12/16/75  11:43:25	PAGE 16
	K1DEF PAL[11,SYS]	PAGE 2 	Switches, absolute locations, registers, mark instructions

					;	USER PROCESS DESCRIPTOR BLOCK
				COMMENT⊗
				
				The PDB contains all of the state information for a user process. 
				The things you need to set up are UFPUSE and UDPUSE, to tell wether
				the process uses floating point; UGRSAV, UFPSAV, and USKSAV if you
				want to give the process some initial information in its general
				registers, floating registers, or stack (if you set USKSAV to 1, you
				must also put a reasonable value into USKP); and UPC for servo
				processes that are scheduled with a SCHED7 operation.  UPDLEN should
				be set to the number of bytes (!) in the process descriptor block. 
				The Kernel sets up the rest. 
					⊗
		000000			.PDB==.
		000000				.OFFSET -.
					PDBSTA::
		000002			UST0::	 .BLKW 1		;Status codes, containing the following:
					
		100000				UFPUSE==100000		;He uses floating point.
		040000				UDPUSE==040000		;He uses double precision.
		020000				UFPSAV==020000		;His floating point stuff is in the PDB.
		010000				USKSAV==010000		;Ditto his stack pointer,
		004000				UGRSAV==004000		;general registers,
		002000				UPCSAV==002000		;PC and PSW.
						;	   377		;Low byte contains 2*(nominal priority).
					
		000004			UPDLEN:: .BLKW 1	;Length of the PDB (bytes).
		000006			USKMIN:: .BLKW 1	;Min and max values for SP.
		000010			USKMAX:: .BLKW 1
		000012			UINTL::	 .BLKW 1	;Link to job this one pre-empted.
		000014			UCALL::	 .BLKW 1	;Kernel SP when this job is interrupted.
					PDBSP::
		000016			USKP::	 .BLKW 1	;Stack pointer,
					PDBPC::
		000020			UPC::	 .BLKW 1	;program counter,
		000022			UPSW::	 .BLKW 1	;and condition codes.
					
				COMMENT⊗	The next six words are where the Kernel stores your
					general registers when your process is inactive.  For jobs
					created with a SCHED7, UGRSAV is forced to 1 in order to
					load the data pointers into your registers.
					⊗
					
					PDBR0::
		000024			UGR0::	 .BLKW 1	;General registers R0-R2
		000026			PDBR1::	 .BLKW 1
		000030			PDBR2::	 .BLKW 1
					PDBR3::
		000032			UADLST:: .BLKW 1	;R3 - AD channel list pointer
	PALX 231	12/16/75  11:43:25	PAGE 17
	K1DEF PAL[11,SYS]	PAGE 2.1 	Switches, absolute locations, registers, mark instructions

					PDBR4::
		000034			UADDAT:: .BLKW 1	;R4 - AD data pointer
		000036			PDBR5::	 .BLKW 1	;R5
					
				COMMENT⊗	The next part is for jobs that use floating point.
					You can leave it out of the PDB for fixed-point-only jobs.
					⊗
					
		000040			UFEC::	 .BLKW 1	;Floating Exception Code and address are
		000042			UFEA::	 .BLKW 1	;stored here when a floating-point trap
								;happens.  You can test for traps by checking
								;the FEC for non-zero (you have to clear it yourself).
					
		000044			UFPS::	 .BLKW 1	;Floating Point Status
					UAC0::			;12 words for the AC's in single precision,
								;24 if UDPUSE is on.
					
						;The rest of the block is your stack.  Any time you become inactive,
						;the kernel checks your stack pointer and gives a horrendous error
						;if it is out of bounds.
					
		000000				.OFFSET 0
		000000			.=.PDB
					.MACRO PDBLK LPDL,FP
						.IF NB FP
						  .IF IDN <FP>,<D>
						    .W.==UFPUSE+UDPUSE
						    .L.==66
						  .IFF
						    .W.==UFPUSE
						    .L.==36
						  .ENDC
						.IFF
						  .W.==0
						  .L.==0
						.ENDC
						.WORD .W.
						.WORD <UFEC-UST0>+.L.+<2*LPDL>
						.BLKB UFEC-USKMIN
						.BLKB 2*LPDL+.L.
					.ENDM
	PALX 231	12/16/75  11:43:25	PAGE 18
	K1DEF PAL[11,SYS]	PAGE 3 	Switches, absolute locations, registers, mark instructions

					;	EMT OPERATIONS
					
					;The following macros are just for my convenience.
					
					.MACRO EMTDEF NAME,PROG,ARGS,PARGS
						  DEFMAC NAME,↑\ARGS\,↑\PARGS\,\NXTEMT
						  NXTEMT==NXTEMT+1
						.ENDM
					
					.MACRO DEFMAC NAME,ARGS,PARGS,EMTNUM
					  .MACRO NAME ARGS
					PARGS	EMTNUM
						.ENDM
					      .ENDM
					
					.MACRO .ARG A
						    .LIF NB A
						      MOV A,-(SP)
						.ENDM
					
		104000			NXTEMT==104000
					
					;Here are the system calls.  I'll explain them later.
					
						EMTDEF DISMIS,.DISMI
						  DEFMAC DISMIS,↑\\,↑\\,\NXTEMT
					  .MACRO DISMIS 
						104000
						.ENDM
		104001				  NXTEMT==NXTEMT+1
					EMTDEF FORK,.FORK,↑\PDB,LOC,PRI\,↑\	  .ARG PRI
					  .ARG LOC
					  .ARG PDB
					\
					  DEFMAC FORK,↑\PDB,LOC,PRI\,↑\	  .ARG PRI
					  .ARG LOC
					  .ARG PDB
					\,\NXTEMT
					  .MACRO FORK PDB,LOC,PRI
						  .ARG PRI
						  .ARG LOC
						  .ARG PDB
						104001
						.ENDM
		104002				  NXTEMT==NXTEMT+1
						EMTDEF EVMAK,.EVMAK
						  DEFMAC EVMAK,↑\\,↑\\,\NXTEMT
					  .MACRO EVMAK 
						104002
	PALX 231	12/16/75  11:43:25	PAGE 19
	K1DEF PAL[11,SYS]	PAGE 3.1 	Switches, absolute locations, registers, mark instructions

						.ENDM
		104003				  NXTEMT==NXTEMT+1
					EMTDEF EVKIL,.EVKIL,E,↑\	  .ARG E
					\
					  DEFMAC EVKIL,↑\E\,↑\	  .ARG E
					\,\NXTEMT
					  .MACRO EVKIL E
						  .ARG E
						104003
						.ENDM
		104004				  NXTEMT==NXTEMT+1
					EMTDEF EVWAIT,.EVWAI,E,↑\	  .ARG E
					\
					  DEFMAC EVWAIT,↑\E\,↑\	  .ARG E
					\,\NXTEMT
					  .MACRO EVWAIT E
						  .ARG E
						104004
						.ENDM
		104005				  NXTEMT==NXTEMT+1
					EMTDEF EVSIG,.EVSIG,E,↑\	  .ARG E
					\
					  DEFMAC EVSIG,↑\E\,↑\	  .ARG E
					\,\NXTEMT
					  .MACRO EVSIG E
						  .ARG E
						104005
						.ENDM
		104006				  NXTEMT==NXTEMT+1
					EMTDEF SLEEP,.SLEEP,MSEC,↑\	  .ARG MSEC
					\
					  DEFMAC SLEEP,↑\MSEC\,↑\	  .ARG MSEC
					\,\NXTEMT
					  .MACRO SLEEP MSEC
						  .ARG MSEC
						104006
						.ENDM
		104007				  NXTEMT==NXTEMT+1
					EMTDEF SCHEDU,.SCHED,↑\JOB,ADR,PRI,MSEC\,↑\	  .ARG MSEC
					  .ARG PRI
					  .ARG ADR
					  .ARG JOB
					\
					  DEFMAC SCHEDU,↑\JOB,ADR,PRI,MSEC\,↑\	  .ARG MSEC
					  .ARG PRI
					  .ARG ADR
					  .ARG JOB
					\,\NXTEMT
					  .MACRO SCHEDU JOB,ADR,PRI,MSEC
	PALX 231	12/16/75  11:43:25	PAGE 20
	K1DEF PAL[11,SYS]	PAGE 3.2 	Switches, absolute locations, registers, mark instructions

						  .ARG MSEC
						  .ARG PRI
						  .ARG ADR
						  .ARG JOB
						104007
						.ENDM
		104010				  NXTEMT==NXTEMT+1
					EMTDEF SETPRI,.SETPR,NEW,↑\	  .ARG NEW
					\
					  DEFMAC SETPRI,↑\NEW\,↑\	  .ARG NEW
					\,\NXTEMT
					  .MACRO SETPRI NEW
						  .ARG NEW
						104010
						.ENDM
		104011				  NXTEMT==NXTEMT+1
					EMTDEF EVTST,.EVTST,E,↑\	  .ARG E
					\
					  DEFMAC EVTST,↑\E\,↑\	  .ARG E
					\,\NXTEMT
					  .MACRO EVTST E
						  .ARG E
						104011
						.ENDM
		104012				  NXTEMT==NXTEMT+1
					EMTDEF SCHED7,.SCHD7,↑\AR,TIM\,↑\	  .ARG TIM
					  .ARG AR
					\
					  DEFMAC SCHED7,↑\AR,TIM\,↑\	  .ARG TIM
					  .ARG AR
					\,\NXTEMT
					  .MACRO SCHED7 AR,TIM
						  .ARG TIM
						  .ARG AR
						104012
						.ENDM
		104013				  NXTEMT==NXTEMT+1
						EMTDEF GETTIM,.GETTI
						  DEFMAC GETTIM,↑\\,↑\\,\NXTEMT
					  .MACRO GETTIM 
						104013
						.ENDM
		104014				  NXTEMT==NXTEMT+1
	PALX 231	12/16/75  11:43:25	PAGE 21
	K1DEF PAL[11,SYS]	PAGE 4 	Switches, absolute locations, registers, mark instructions

					;	EXPLANATIONS OF THE SYSTEM CALLS
					
				COMMENT⊗  All system calls pop their arguments off the User stack
					and push their return values if they have any.  They mostly
					return with the C condition code bit zero.  An error condition
					causes a return with C=1; in that case, the arguments have
					been popped and no return values pushed.
				
				
					LEVEL 7 PROCESSES
				
					Only one of these can be scheduled for any given time slot.
					When the Kernel starts a level 7 job running, it interprets
					the contents of User registers 3 and 4 in the PDB as pointers
					to two data arrays.  R3 points at a list of ADC channel numbers
					(one per word) terminated by a negative number.  The startup
					routine reads all the channels specified in the array and puts
					the results into the corresponding locations in the array that
					R4 points at.  When the user process gets control, R3 and R4
					point at the first words of the two arrays and all of the
					channels have been read.  The recommended way for a level 7
					job to reschedule itself is to do a SCHED7 to its own PDB,
					take note of the returned actual time interval, and then
					DISMIS (details below).  This procedure minimizes overhead
					by not saving and restoring the registers.  NOTE: Since level 7
					can not be interrupted by (even by floating-point traps), I don't
					bother to allocate PDB space for any of the floating-point stuff.
				
				
				DISMIS (no arguments)
				
				Kills the process that uses it.  It saves the PC, PSW, and SP but nothing else.
				If the process is restarted (as in the level 7 SCHED7-DISMIS sequence) it will
				resume after the DISMIS with the stack in the right state but all registers
				clobbered.  R3 through R5 will be reloaded with what they had at the first
				startup.
				
				
				FORK PDB,LOC,PRI
				
				Starts up a new process immediately.  PDB points at
				a process descriptor, LOC is the starting address, and PRI is the
				priority of the new process.  If PRI is higher than that of the
				calling process the new one will run immediately and pre-empt the
				caller.  FORKing with PRI=7 will work but is not a good idea since
				if you do it too late in a clock period the clock might miss a tick.
				
				
				SCHEDU PDB,LOC,PRI,TIME
	PALX 231	12/16/75  11:43:25	PAGE 22
	K1DEF PAL[11,SYS]	PAGE 4.1 	Switches, absolute locations, registers, mark instructions

				
				Works just like FORK except that instead
				of starting the target process immediately it puts the process on
				the clock queue to start up (TIME) milliseconds from now.  This will
				also work if PRI=7, but if another level 7 process is already scheduled
				for that slot the new one will be put into the queue in the first
				available slot after the one you requested.
				
				
				SCHED7 ARRAY,TIME
				
				Is a special variation on SCHEDU to allow scheduling
				a whole bunch of priority 7 jobs at one whack.  ARRAY points at (what
				else) which consists of a pointer to a PDB, a return value, another
				PDB pointer, another return value, etc., ending with a zero where the
				next PDB pointer should be.  TIME is the number of milliseconds from
				now that the first process should start up.  SCHED7 puts the processes
				into consecutive time slots if it can.  If a slot is already filled,
				it uses the next available one.  In any case, it returns for each
				process the number of number of milliseconds from now that it wound
				up being scheduled.
				
				
				SLEEP TIME
				
				Puts the requesting process to sleep for (TIME) milliseconds.
				If TIME=0, this merely reschedules you for the present time slot.
				If your priority is 7 and the time you requested is taken, you will
				be scheduled in the first later available slot.
				
				
				EVMAK (no args)
				
				Creates an event with its associated counter and
				empty queue of jobs waiting.  It returns a unique identifier which
				you can use later to refer to the event.  Events come in two flavors:
				the kind you create with this operation, and "permanent" ones that
				reflect hardware conditions.  Permanent events are identified by
				small integers.  I'll add their descriptions and identifiers as I
				add the events.
				
				
				EVKIL <event id>
				
				Destroys the event if it was one that you created,
				waking up any processes that are waiting and giving them the C=1
				return.  If the id doesn't point at an event, or points to a permanent
				event, EVKIL does nothing and gives the error return.
				
	PALX 231	12/16/75  11:43:25	PAGE 23
	K1DEF PAL[11,SYS]	PAGE 4.2 	Switches, absolute locations, registers, mark instructions

				
				EVSIG <event id>
				
				Signals the event.  If any processes are waiting, the
				first one will wake up.  EVSIG of a permanent event does nothing but
				give the error return.
				
				
				EVWAIT <event id>
				
				Tests the event (of either type) and makes the normal
				return if it has happened.  If it hasn't happened, your process goes
				to sleep waiting for it and gets the normal return when it does happen.
				If it is not an event, or it has been EVKILled while you were waiting,
				you get the error return.  The queue of jobs waiting on an event is
				ordered by their nominal priorities, first come first served within
				priority levels.
				
				
				EVTST <event id>
				
				Tests the event and returns normally if it has happened.
				If it hasn't, or if it's a non-event, you get the error return with no
				waiting.
				
				
				SETPRI PRI
				
				Sets your priority to PRI or the priority you were originally
				run at, whichever is higher, and returns your old priority on the stack.
				If you attempted to set your priority below the original, it returns C=1.
				
				
				GETTIM (no args)
				
				Returns on your stack the time in milliseconds since the Kernel was last
				initialized.  The result is a two-word integer in the right format for
				a LDCLF or LDCLD instruction.
					⊗
	PALX 231	12/16/75  11:43:25	PAGE 24
	K1DEF PAL[11,SYS]	PAGE 5 	Switches, absolute locations, registers, mark instructions

		014000			USRORG==14000
		013774			JOBDAT==USRORG-4		;Location of the descriptor block for your
								;main program.
		013776			JOBSA==USRORG-2		;Starting address of your main program.
					
		014000			.=USRORG
	PALX 231	12/16/75  11:43:25	PAGE 25
	HALIO PAL[HAL,HE]	PAGE 4.1 	Switches, absolute locations, registers, mark instructions

					.INSRT HALIO.PAL[HAL,HE]
	PALX 231	12/16/75  11:43:25	PAGE 26
	HALIO PAL[HAL,HE]	PAGE 1 	Switches, absolute locations, registers, mark instructions

				COMMENT ⊗   VALID 00005 PAGES
				C REC  PAGE   DESCRIPTION
				C00001 00001
				C00002 00002	.SBTTL	Basic TTY input and output routines
				C00003 00003	 TTY output routines  TYPSTR, TYPDEC, TYPOCT, TYPCHR
				C00008 00004	 Macros:  OUTSTR, NUMOUT, ASCIE, CRLF, HALERR, ERRTRAP
				C00011 00005	 INSTR, system line buffers
				C00014 ENDMK
					C⊗;
	PALX 231	12/16/75  11:43:25	PAGE 27
	HALIO PAL[HAL,HE]	PAGE 2 	Basic TTY input and output routines

					.SBTTL	Basic TTY input and output routines
		014000			.EVEN
					
	PALX 231	12/16/75  11:43:25	PAGE 28
	HALIO PAL[HAL,HE]	PAGE 3 	Basic TTY input and output routines

					; TTY output routines  TYPSTR, TYPDEC, TYPOCT, TYPCHR
					
					;  Modified 5-Sep-74 by RF.  Originally written by KKP.
					
				COMMENT ⊗ Output a string, ending with a zero character. Pointer to
					start of string in R0.  Called in "simple" style. ⊗
					
	014000	010001			TYPSTR:	MOV R0,R1	;R1 ← LOC[STRING]
	014002	112100				MOVB (R1)+,R0	;R0 ← first byte of string
	014004	001404			TSLOOP:	BEQ TYPS1	;If null, exit now.
	014006	004767	000056			JSR PC,TYPCHR	;Type this one character
	014012	112100				MOVB (R1)+,R0	;R0 ← Next byte of string
	014014	001373				BNE TSLOOP	;If more to come, repeat.
	014016	000207			TYPS1:	RTS PC		;Done
					
					
				COMMENT ⊗ Routines to output numbers.  Argument in R0.  TYPDEC
				outputs in base 10, and TYPOCT in base 8.  Both use TYPDIG as a
				subroutine, putting the digit in R0.  TYPCHR is a general purpose
				character output routine.  It looks at OUTSW to see where to direct
					the output. ⊗
					
	014020	012767	000012	000020	TYPDEC:	MOV #12,RADIX	;To output in base 10
	014026	000404				BR TYPDIG	;Go type it.
	014030	012767	000010	000010	TYPOCT:	MOV #8,RADIX	;To output in base 8.
	014036	000400				BR TYPDIG	;Go type it.
	014040	010001			TYPDIG:	MOV R0,R1	;Need dividend in R1, with R0 clear.
	014042	005000				CLR R0		;Clear upper half of dividend.
	014044	071027				DIV (PC)+,R0	;Divide argument in R0, R1 by radix.
	014046	000012			RADIX:	12		;Starts out in decimal.
	014050	001404				BEQ TYPOUT	;If quotient zero, then can print.
	014052	010146				MOV R1,-(SP)	;Else stack quotient
	014054	004767	177760			JSR PC,TYPDIG	;Recursive call.
	014060	012601				MOV (SP)+,R1	;Unstack last quotient
	014062	062701	000060		TYPOUT:	ADD #'0,R1	;Form TTY code for digit
	014066	010100				MOV R1,R0	;Need argument for TYPCHR in R0.
	014070	005767	143676		TYPCHR:	TST OUTSW	;VT05 or console?
	014074	001420				BEQ TYPCH1	;
	014076	105767	163462			TSTB KBOS	;VT05: Is it available?
	014102	100401				BMI TYPCH2	;Yes.
					TYPCH3:
					    .IFDF KERNEL
					    .IFNZ KERNEL
						SLEEP #1	;No.  Sleep a while, try again
					    .ENDC
					    .ENDC
	014104	000771				BR TYPCHR	;
	014106	110067	163454		TYPCH2:	MOVB R0,KBOR	;Output a byte to it.
	014112	022700	000012			CMP #12,R0	;Was it a line feed?
	PALX 231	12/16/75  11:43:25	PAGE 29
	HALIO PAL[HAL,HE]	PAGE 3.1 	Basic TTY input and output routines

	014116	001014				BNE TYPRET	;If not that code, then done.
	014120	005000				CLR R0		;Otherwise, output 3 nulls.
	014122	004767	177742			JSR PC,TYPCHR	;
	014126	004767	177736			JSR PC,TYPCHR	;
	014132	000167	177732			JMP TYPCHR	;Direct jump; it will return to caller.
	014136	105767	143634		TYPCH1:	TSTB OREG	;Console:  Ready?
	014142	001360				BNE TYPCH3	;No.
	014144	110067	143626			MOVB R0,OREG	;Yes.  Output a byte to it.
	014150	000207			TYPRET:	RTS PC		;Return.
	PALX 231	12/16/75  11:43:25	PAGE 30
	HALIO PAL[HAL,HE]	PAGE 4 	Basic TTY input and output routines

					; Macros:  OUTSTR, NUMOUT, ASCIE, CRLF, HALERR, ERRTRAP
					
					       .MACRO OUTSTR B	;Type string starting at B.
						MOV R0,-(SP)	;Save R0.  Who knows what was happening in it?
						MOV R1,-(SP)	;Save R1.
						MOV #B,R0	;Load up the string to be output
						JSR PC,TYPSTR	;Call the string output utility routine.
						MOV (SP)+,R1	;Restore R1.
						MOV (SP)+,R0	;Restore R0.
					       .ENDM
					
					       .MACRO NUMOUT	;Type out the number in AC0 with CVG using OUTBUF
						MOV R0,-(SP)	;Save the registers
						MOV R1,-(SP)
						STF AC0,-(SP)
						STF AC1,-(SP)
						MOV #OUTBUF,R0	;Use OUTBUF to construct the string
						JSR PC,CVG	;Convert floating point number to asc
						LDF (SP)+,AC1   ;Restore the floating point registers
						LDF (SP)+,AC0
						MOV #OUTBUF,R0	;Set pointer for i/o routine
						JSR PC,TYPSTR	;Type out the number
						MOV (SP)+,R1	;Restore the registers
						MOV (SP)+,R0
					       .ENDM
					
					       .MACRO ASCIE STR
					       .ASCIZ STR
					       .EVEN
					       .ENDM
					
					       .MACRO	CRLF
						OUTSTR CRLFX	;Carriage return, line feed.
					       .ENDM
					
	014152	   015		
	014153	   012			CRLFX: .ASCIZ /
	014154	   000		
					/
					
				RUGMES:	ASCIE </π
				--ONLY DDT CAN HELP YOU NOW!
					π/>
	014155	   007		
	014156	   015		
	014157	   012			       .ASCIZ /π
	014160	   055		
	014161	   055		
	014162	   117		
	PALX 231	12/16/75  11:43:25	PAGE 31
	HALIO PAL[HAL,HE]	PAGE 4.1 	Basic TTY input and output routines

	014163	   116		
	014164	   114		
	014165	   131		
	014166	   040		
	014167	   104		
	014170	   104		
	014171	   124		
	014172	   040		
	014173	   103		
	014174	   101		
	014175	   116		
	014176	   040		
	014177	   110		
	014200	   105		
	014201	   114		
	014202	   120		
	014203	   040		
	014204	   131		
	014205	   117		
	014206	   125		
	014207	   040		
	014210	   116		
	014211	   117		
	014212	   127		
	014213	   041		
	014214	   015		
	014215	   012			--ONLY DDT CAN HELP YOU NOW!
	014216	   007		
	014217	   000		
					π/
		014220			       .EVEN
					
					       .MACRO HALERR MES	;Bad error.  Type message, call debugger.
						MOV #MES,-(SP)	;Push the message pointer.
						JSR PC,ERRTRAP	;No need to save registers.  This is done in ERRTRAP.
					       .ENDM
					
					ERRTRAP:
					; Pointer to message is on stack.  Print it, restore state, go to DDT
	014220	010046				MOV R0,-(SP)	;Save R0.
	014222	010146				MOV R1,-(SP)	;Save R1.
	014224	012700	014152			MOV #CRLFX,R0	;Move to new line
	014230	004767	177544			JSR PC,TYPSTR	;
	014234	016600	000006			MOV 6(SP),R0	;Type out message
	014240	004767	177534			JSR PC,TYPSTR	;
	014244	012700	014155			MOV #RUGMES,R0	;Type out RUGMES
	014250	004767	177524			JSR PC,TYPSTR	;
	014254	012601				MOV (SP)+,R1	;Restore R1.
	014256	012600				MOV (SP)+,R0	;Restore R0.
	PALX 231	12/16/75  11:43:25	PAGE 32
	HALIO PAL[HAL,HE]	PAGE 4.2 	Basic TTY input and output routines

	014260	012616				MOV (SP)+,(SP)	;put return address only on stack.
	014262	000003				BPT		;Breakpoint to DDT.
	014264	000207				RTS PC		;Return to calling point.
					
	PALX 231	12/16/75  11:43:25	PAGE 33
	HALIO PAL[HAL,HE]	PAGE 5 	Basic TTY input and output routines

					; INSTR, system line buffers
					
				COMMENT ⊗ String byte pointer argument in R0.  A carriage return is
				assumed to be the activation character. A rubout is a deleting
				backspace character.  At the completion of this routine a null
				character is placed at the end of the input string.  R0 then points
				to the null character.  Registers used: R0 passes the argument, R1 is
					garbaged.  ⊗
					
	014266	005067	000154		INSTR:	CLR	CCNT		;RESET CHARACTER COUNT
	014272	105767	163262		IN2:  	TSTB	KBIS		;TEST IF KEYBOARD READY
	014276	001775				BEQ	.-4		;WAIT TILL IT IS
	014300	116701	163256			MOVB	KBIR,R1		;GET A CHARACTER
	014304	042701	177600			BIC     #177600,R1		;MASK OFF - MAKE IT 7 BITS
	014310	020127	000177			CMP	R1,#177		;COMPARE TO BS CHARACTER
	014314	001020				BNE	IN3		;SKIP IF ITS NOT
	014316	005767	000124			TST	CCNT		;CHECK IF ANY CHARACTERS IN BUFFER
	014322	001763				BEQ	IN2		;FORGET BACK SPACE IF NO CHAR.
	014324	005300				DEC     R0   		;REMOVE LAST CHARACTER IN BUFFER
	014326	005367	000114			DEC	CCNT		;DECREMENT CHARACTER COUNT
						OUTSTR  DBS		;PERFORM A DELETING BACKSPACE
	014332	010046				MOV R0,-(SP)	;Save R0.  Who knows what was happening in it?
	014334	010146				MOV R1,-(SP)	;Save R1.
	014336	012700	014450			MOV #DBS,R0	;Load up the string to be output
	014342	004767	177432			JSR PC,TYPSTR	;Call the string output utility routine.
	014346	012601				MOV (SP)+,R1	;Restore R1.
	014350	012600				MOV (SP)+,R0	;Restore R0.
	014352	000167	177714			JMP     IN2
	014356	020127	000015		IN3:	CMP	R1,#15		;COMPARE TO CR CHARACTER
	014362	001415				BEQ     IN4   		;CONTINUE READING IF ITS NOT A CR
	014364	020127	000040			CMP	R1,#40		;CHECK IF CHARACTER LEGAL
	014370	002740				BLT	IN2		;IGNOR IF IT IS
	014372	110120			    	MOVB	R1,(R0)+	;SAVE THE CHARACTER
	014374	005267	000046		    	INC	CCNT		;INCREMENT CHARACTER COUNT
	014400	105767	163160		     	TSTB	KBOS		;ECHO THE CHARACTER
	014404	100375				BPL	.-4		;WAIT TILL TTY READY
	014406	110167	163154			MOVB	R1,KBOR		;WRITE THE CHARACTER
	014412	000167	177654			JMP	IN2		;CONTINUE READING
					IN4:  	CRLF			;IF IT IS A CR, TYPE A CR AND LF
						OUTSTR CRLFX	;Carriage return, line feed.
	014416	010046				MOV R0,-(SP)	;Save R0.  Who knows what was happening in it?
	014420	010146				MOV R1,-(SP)	;Save R1.
	014422	012700	014152			MOV #CRLFX,R0	;Load up the string to be output
	014426	004767	177346			JSR PC,TYPSTR	;Call the string output utility routine.
	014432	012601				MOV (SP)+,R1	;Restore R1.
	014434	012600				MOV (SP)+,R0	;Restore R0.
	014436	110120				MOVB	R1,(R0)+	;PUT A CR IN THE STRING
	014440	112710	000000			MOVB    #0,(R0)		;PUT IN A NULL CHARACTER
	014444	000207				RTS	PC		;RETURN
	PALX 231	12/16/75  11:43:25	PAGE 34
	HALIO PAL[HAL,HE]	PAGE 5.1 	Basic TTY input and output routines

	014446	000000			CCNT:	0
	014450	   010		
	014451	   040		
	014452	   010		
	014453	   000			DBS:	.BYTE	10,40,10,0
					
					;System line buffers
					
		014600			INBUF:	.BLKW	42.
		014724			OUTBUF:	.BLKW	42.
	014724	014454			CURIN:	INBUF		;Current line pointer
	PALX 231	12/16/75  11:43:25	PAGE 35
	MAP PAL[HAL,HE]	PAGE 4.1 	Basic TTY input and output routines

					
					MAINBL:	PDBLK 100,S	;Makes a process descriptor for main process
						.IF NB S
						  .IF IDN <S>,<D>
						    .W.==UFPUSE+UDPUSE
						    .L.==66
						  .IFF
		100000				    .W.==UFPUSE
		000036				    .L.==36
						  .ENDC
						.IFF
						  .W.==0
						  .L.==0
						.ENDC
	014726	100000				.WORD .W.
	014730	000274				.WORD <UFEC-UST0>+.L.+<2*100>
		014764				.BLKB UFEC-USKMIN
		015222				.BLKB 2*100+.L.
					
						PUTLOC JOBDAT, MAINBL
		015222			        II==.
		013774			        .= JOBDAT
	013774	014726			         MAINBL
		015222			       .=II
						PUTLOC JOBSA, DRIVER
		015222			        II==.
		013776			        .= JOBSA
	013776	016270			         DRIVER
		015222			       .=II
					
		015322			LTAB:	.BLKW 40	;Enough for 20 links
	015322	016506			LHI0:	HI0
	015324	000000				0
	015326	040000			LHI1:	HI1
	015330	000001				1
	015332	060000			LHI2:	HI2
	015334	000002				2
	015336	100000			LHI3:	HI3
	015340	000003				3
					
				COMMENT ⊗
				If you want to define where, say, FOO is, you should do this:
					PUTLOC LFOO, FOO	;The address
					PUTLOC LFOO+2, 2	;Assuming that you are in county 2
				If you want to call, say, FOO, you should do this:
					MOV #LFOO,-(SP)		;This will get cleared off.
					JSR PC,SWITCH		;Will even do the return properly
					⊗
	PALX 231	12/16/75  11:43:25	PAGE 36
	MAP PAL[HAL,HE]	PAGE 5 	Basic TTY input and output routines

					;  COMMON, PINIT, TOSPC
					
					COMMON:
				Comment ⊗ Takes the page table start address in R0 (PTAB0:PTAB3).
				Sets virtual memory 0-17777 and 120000-177777 to the equivalent
					physical memory.  ⊗
	015342	010246				MOV R2,-(SP)	;Save R2
	015344	012701	034000			MOV #UNIBIT+WRPERM+RDPERM,R1	;Page table entry
	015350	012702	000010			MOV #10,R2	;Number of entries for low common page table
	015354	010120			COM1:	MOV R1,(R0)+	;Put in the entry
	015356	005201				INC R1		;Set for next physical page
	015360	077203				SOB R2,COM1	;Repeat
						;R0 is now set to word 10, R1 to physical page 10.
					
	015362	062700	000100			ADD #100,R0	;R0 set to word 50 (virt. add. 120000)
	015366	062701	000040			ADD #40,R1	;R1 set to page 50 (phys. add. 120000)
	015372	012702	000020			MOV #20,R2	;Number of entries for mid common page table
	015376	010120			COM2:	MOV R1,(R0)+	;Put in the entry
	015400	005201				INC R1		;Set for next physical page
	015402	077203				SOB R2,COM2	;Repeat
					
	015404	012701	034370			MOV #UNIBIT+WRPERM+RDPERM+370,R1	;page 370 (phys. add. 760000)
	015410	012702	000010			MOV #10,R2	;Number of entries for high common page table
	015414	010120			COM3:	MOV R1,(R0)+	;Put in the entry
	015416	005201				INC R1		;Set for next physical page
	015420	077203				SOB R2,COM3	;Repeat
					
	015422	012602				MOV (SP)+,R2	;Restore R2
	015424	000207				RTS PC		;Done
					
					PINIT:
	015426	012767	016266	000430		MOV #SWSTCK,PTR	;Initialize the special stack
					
					;  Set up the four page tables
					
	015434	012700	166000			MOV #PTAB0,R0	;Clear all page table entries to start with
	015440	012701	000400			MOV #400,R1	;
	015444	005020			PINI0:	CLR (R0)+	;
	015446	077102				SOB R1,PINI0	;
					
						;Page table 0
	015450	012700	166000			MOV #PTAB0,R0	;
	015454	004767	177662			JSR PC,COMMON	;
	015460	012701	034010			MOV #UNIBIT+WRPERM+RDPERM+10,R1	;Page table entry
	015464	012702	000004			MOV #4,R2	;Number of entries for the distinct page table
	015470	012700	166020			MOV #PTAB0+20,R0;Page table entry
	015474	010120			PINI1:	MOV R1,(R0)+	;Put in the entry
	015476	005201				INC R1		;Set for next physical page
	015500	077203				SOB R2,PINI1	;Repeat
	PALX 231	12/16/75  11:43:25	PAGE 37
	MAP PAL[HAL,HE]	PAGE 5.1 	Basic TTY input and output routines

					
						;Page table 1
	015502	012700	166200			MOV #PTAB1,R0	;
	015506	004767	177630			JSR PC,COMMON	;
	015512	012701	034014			MOV #UNIBIT+WRPERM+RDPERM+14,R1	;Page table entry
	015516	012702	000004			MOV #4,R2	;Number of entries for the distinct page table
	015522	012700	166220			MOV #PTAB1+20,R0;Page table entry
	015526	010120			PINI2:	MOV R1,(R0)+	;Put in the entry
	015530	005201				INC R1		;Set for next physical page
	015532	077203				SOB R2,PINI2	;Repeat
					
					
						;Page table 2
	015534	012700	166400			MOV #PTAB2,R0	;
	015540	004767	177576			JSR PC,COMMON	;
	015544	012701	034020			MOV #UNIBIT+WRPERM+RDPERM+20,R1	;Page table entry
	015550	012702	000004			MOV #4,R2	;Number of entries for the distinct page table
	015554	012700	166420			MOV #PTAB2+20,R0;Page table entry
	015560	010120			PINI3:	MOV R1,(R0)+	;Put in the entry
	015562	005201				INC R1		;Set for next physical page
	015564	077203				SOB R2,PINI3	;Repeat
					
					
						;Page table 3
	015566	012700	166600			MOV #PTAB3,R0	;
	015572	004767	177544			JSR PC,COMMON	;
	015576	012701	034024			MOV #UNIBIT+WRPERM+RDPERM+24,R1	;Page table entry
	015602	012702	000004			MOV #4,R2	;Number of entries for the distinct page table
	015606	012700	166620			MOV #PTAB3+20,R0;Page table entry
	015612	010120			PINI4:	MOV R1,(R0)+	;Put in the entry
	015614	005201				INC R1		;Set for next physical page
	015616	077203				SOB R2,PINI4	;Repeat
					
						;turn it all on, hope it works.
	015620	005000			PINI5:	CLR R0		;Set all to map 0
	015622	004767	000010			JSR PC,TOSPC	;
	015626	012767	100000	151144		MOV #MAPENB,STATR0	;Turns it on.
	015634	000207				RTS PC		;Done
					
				TOSPC:	Comment ⊗ R0 has 0, 1, 2, 3.  We want to move the user
					to that space.  Change both the I and D spaces.  ⊗
	015636	072027	000010			ASH #10,R0	;
	015642	062700	000176			ADD #176,R0	;Maximum accessible page
	015646	010067	151146			MOV R0,KISPCE	;Set the instruction space
	015652	010067	151152			MOV R0,KDSPCE	;Set the data space
	015656	010067	151140			MOV R0,SISPCE	;Set the instruction space
	015662	010067	151144			MOV R0,SDSPCE	;Set the data space
	015666	010067	151132			MOV R0,NISPCE	;Set the instruction space
	015672	010067	151136			MOV R0,NDSPCE	;Set the data space
	PALX 231	12/16/75  11:43:25	PAGE 38
	MAP PAL[HAL,HE]	PAGE 5.2 	Basic TTY input and output routines

	015676	010067	151124			MOV R0,UISPCE	;Set the instruction space
	015702	010067	151130			MOV R0,UDSPCE	;Set the data space
	015706	000207				RTS PC		;Done
	PALX 231	12/16/75  11:43:25	PAGE 39
	MAP PAL[HAL,HE]	PAGE 6 	Basic TTY input and output routines

					;  SWITCH
					
					SWITCH:
					COMMENT ⊗ The stack holds a pointer into the LTAB. ⊗
					
	015710	010046				MOV R0,-(SP)	;Save R0
	015712	010146				MOV R1,-(SP)	;Save R1
	015714	016701	000144			MOV PTR,R1	;The stack for this routine
	015720	016641	000004			MOV 4(SP),-(R1)	;Save the return address
	015724	016741	151076			MOV UISPCE,-(R1)	;Where we are coming from
	015730	016641	000006			MOV 6(SP),-(R1)	;Save the pointer into the LTAB
	015734	011100				MOV (R1),R0	;R0 ← pointer into LTAB
	015736	016000	000002			MOV 2(R0),R0	;R0 ← desired county
	015742	004767	177670			JSR PC,TOSPC	;Now we have the right county.
	015746	012100				MOV (R1)+,R0	;R0 ← pointer into LTAB
	015750	010167	000110			MOV R1,PTR	;
	015754	011067	000102			MOV (R0),TEMP 	;Stack the address to jump to
	015760	012601				MOV (SP)+,R1	;Restore R1
	015762	012600				MOV (SP)+,R0	;Restore R0
	015764	005726				TST (SP)+	;Get rid of old return address
	015766	005726				TST (SP)+	;Get rid of the pointer to LTAB
					
	015770	004777	000066			JSR PC,@TEMP	;Jump to the routine, return here
					
	015774	017767	000064	151024		MOV @PTR,UISPCE	;Go back to old space
	016002	017767	000056	151026		MOV @PTR,UDSPCE
	016010	017767	000050	151004		MOV @PTR,SISPCE
	016016	017767	000042	151006		MOV @PTR,SDSPCE
	016024	017767	000034	150766		MOV @PTR,KISPCE
	016032	017767	000026	150770		MOV @PTR,KDSPCE
	016040	062767	000002	000016		ADD #2,PTR	;
	016046	017746	000012			MOV @PTR,-(SP)	;The return address
	016052	062767	000002	000004		ADD #2,PTR	;
	016060	000207				RTS PC		;Return
					
		016064			TEMP:	.BLKW 1		;Variable in SWITCH
		016066			PTR:	.BLKW 1		;Variable in SWITCH
		016266				.BLKW 100	;Stack used in SWITCH
		016270			SWSTCK: .BLKW 1		;Top of stack
	PALX 231	12/16/75  11:43:25	PAGE 40
	MAP PAL[HAL,HE]	PAGE 7 	Basic TTY input and output routines

					;  DRIVER
					
					DRIVER:
	016270	004767	177132			JSR PC,PINIT	;
	016274	012746	015322			MOV #LHI0,-(SP)	;
	016300	004767	177404			JSR PC,SWITCH	;
						DISMIS		;
	016304	104000				104000
					
		016506			PATCH:	.BLKW 100	;Patch area
	PALX 231	12/16/75  11:43:25	PAGE 41
	MAP PAL[HAL,HE]	PAGE 8 	Basic TTY input and output routines

					;  Area zero
					
					.MACRO PLACE PHYS,VIRT
					    .OFFSET 0
					    .=PHYS
					    .OFFSET PHYS-VIRT
					.ENDM
					
					
					HI0:
	016506	012700	016540			MOV #MESI0,R0	;Say hello
	016512	004767	175262			JSR PC,TYPSTR	;
	016516	012746	015326			MOV #LHI1,-(SP);
	016522	004767	177162			JSR PC,SWITCH	;
	016526	012700	016562			MOV #MESF0,R0	;Say goodbye
	016532	004767	175242			JSR PC,TYPSTR	;
	016536	000207				RTS PC		;Done
					
				MESI0:	ASCIE </
					INTO AREA ZERO/>
	016540	   015		
	016541	   012			       .ASCIZ /
	016542	   111		
	016543	   116		
	016544	   124		
	016545	   117		
	016546	   040		
	016547	   101		
	016550	   122		
	016551	   105		
	016552	   101		
	016553	   040		
	016554	   132		
	016555	   105		
	016556	   122		
	016557	   117		
	016560	   000		
					INTO AREA ZERO/
		016562			       .EVEN
				MESF0:	ASCIE </
					OUT OF AREA ZERO/>
	016562	   015		
	016563	   012			       .ASCIZ /
	016564	   117		
	016565	   125		
	016566	   124		
	016567	   040		
	016570	   117		
	016571	   106		
	PALX 231	12/16/75  11:43:25	PAGE 42
	MAP PAL[HAL,HE]	PAGE 8.1 	Basic TTY input and output routines

	016572	   040		
	016573	   101		
	016574	   122		
	016575	   105		
	016576	   101		
	016577	   040		
	016600	   132		
	016601	   105		
	016602	   122		
	016603	   117		
	016604	   000		
					OUT OF AREA ZERO/
		016606			       .EVEN
					
					
					PLACE 30000,20000
		000000			    .OFFSET 0
		030000			    .=30000
		010000			    .OFFSET 30000-20000
					
					HI1:
	030000	012700	040032			MOV #MESI1,R0	;Say hello
	030004	004767	153770			JSR PC,TYPSTR	;
	030010	012746	015332			MOV #LHI2,-(SP);
	030014	004767	155670			JSR PC,SWITCH	;
	030020	012700	040052			MOV #MESF1,R0	;Say goodbye
	030024	004767	153750			JSR PC,TYPSTR	;
	030030	000207				RTS PC		;Done
					
				MESI1:	ASCIE </
					INTO AREA ONE/>
	030032	   015		
	030033	   012			       .ASCIZ /
	030034	   111		
	030035	   116		
	030036	   124		
	030037	   117		
	030040	   040		
	030041	   101		
	030042	   122		
	030043	   105		
	030044	   101		
	030045	   040		
	030046	   117		
	030047	   116		
	030050	   105		
	030051	   000		
					INTO AREA ONE/
		030052			       .EVEN
	PALX 231	12/16/75  11:43:25	PAGE 43
	MAP PAL[HAL,HE]	PAGE 8.2 	Basic TTY input and output routines

				MESF1:	ASCIE </
					OUT OF AREA ONE/>
	030052	   015		
	030053	   012			       .ASCIZ /
	030054	   117		
	030055	   125		
	030056	   124		
	030057	   040		
	030060	   117		
	030061	   106		
	030062	   040		
	030063	   101		
	030064	   122		
	030065	   105		
	030066	   101		
	030067	   040		
	030070	   117		
	030071	   116		
	030072	   105		
	030073	   000		
					OUT OF AREA ONE/
		030074			       .EVEN
					
					
					PLACE 40000,20000
		000000			    .OFFSET 0
		040000			    .=40000
		020000			    .OFFSET 40000-20000
					
					HI2:
	040000	012700	060032			MOV #MESI2,R0	;Say hello
	040004	004767	133770			JSR PC,TYPSTR	;
	040010	012746	015336			MOV #LHI3,-(SP);
	040014	004767	135670			JSR PC,SWITCH	;
	040020	012700	060052			MOV #MESF2,R0	;Say goodbye
	040024	004767	133750			JSR PC,TYPSTR	;
	040030	000207				RTS PC		;Done
					
				MESI2:	ASCIE </
					INTO AREA TWO/>
	040032	   015		
	040033	   012			       .ASCIZ /
	040034	   111		
	040035	   116		
	040036	   124		
	040037	   117		
	040040	   040		
	040041	   101		
	040042	   122		
	PALX 231	12/16/75  11:43:25	PAGE 44
	MAP PAL[HAL,HE]	PAGE 8.3 	Basic TTY input and output routines

	040043	   105		
	040044	   101		
	040045	   040		
	040046	   124		
	040047	   127		
	040050	   117		
	040051	   000		
					INTO AREA TWO/
		040052			       .EVEN
				MESF2:	ASCIE </
					OUT OF AREA TWO/>
	040052	   015		
	040053	   012			       .ASCIZ /
	040054	   117		
	040055	   125		
	040056	   124		
	040057	   040		
	040060	   117		
	040061	   106		
	040062	   040		
	040063	   101		
	040064	   122		
	040065	   105		
	040066	   101		
	040067	   040		
	040070	   124		
	040071	   127		
	040072	   117		
	040073	   000		
					OUT OF AREA TWO/
		040074			       .EVEN
					
					
					PLACE 50000,20000
		000000			    .OFFSET 0
		050000			    .=50000
		030000			    .OFFSET 50000-20000
					
					HI3:
	050000	012700	100022			MOV #MESI3,R0	;Say hello
	050004	004767	113770			JSR PC,TYPSTR	;
	050010	012700	100044			MOV #MESF3,R0	;Say goodbye
	050014	004767	113760			JSR PC,TYPSTR	;
	050020	000207				RTS PC		;Done
					
				MESI3:	ASCIE </
					INTO AREA THREE/>
	050022	   015		
	050023	   012			       .ASCIZ /
	PALX 231	12/16/75  11:43:25	PAGE 45
	MAP PAL[HAL,HE]	PAGE 8.4 	Basic TTY input and output routines

	050024	   111		
	050025	   116		
	050026	   124		
	050027	   117		
	050030	   040		
	050031	   101		
	050032	   122		
	050033	   105		
	050034	   101		
	050035	   040		
	050036	   124		
	050037	   110		
	050040	   122		
	050041	   105		
	050042	   105		
	050043	   000		
					INTO AREA THREE/
		050044			       .EVEN
				MESF3:	ASCIE </
					OUT OF AREA THREE/>
	050044	   015		
	050045	   012			       .ASCIZ /
	050046	   117		
	050047	   125		
	050050	   124		
	050051	   040		
	050052	   117		
	050053	   106		
	050054	   040		
	050055	   101		
	050056	   122		
	050057	   105		
	050060	   101		
	050061	   040		
	050062	   124		
	050063	   110		
	050064	   122		
	050065	   105		
	050066	   105		
	050067	   000		
					OUT OF AREA THREE/
		050070			       .EVEN
						PUTLOC LHI3, HI3	;The address
		100070			        II==.
		165336			        .= LHI3
	165336	100000			         HI3
		050070			       .=II
						PUTLOC LHI3+2, 3	;County
		100070			        II==.
	PALX 231	12/16/75  11:43:25	PAGE 46
	MAP PAL[HAL,HE]	PAGE 8.5 	Basic TTY input and output routines

		165340			        .= LHI3+2
	165340	000003			         3
		050070			       .=II
					
	PALX 231	12/16/75  11:43:25	PAGE 47
	MAP PAL[HAL,HE]	PAGE 9 	Basic TTY input and output routines

		000001			.END
	PALX 231	12/16/75  11:43:25	PAGE 48
	MAP PAL[HAL,HE]	PAGE 9 	***SYMBOL TABLE***      

	AC0	000000RH		KBOR	177566		PATCH	016306		TRANSP	000200H	
	AC1	000001RH		KBOS	177564		PC	000007R		TSLOOP	014004	
	AC2	000002RH		KDSPCE	167030		PCODE	054000		TYPCH1	014136	
	AC3	000003RH		KERNEL	000000U		PDBPC	000016H		TYPCH2	014106	
	AC4	000004RH		KISPCE	167020		PDBR0	000022H		TYPCH3	014104	
	AC5	000005RH		LCENTE	014010H		PDBR1	000024H		TYPCHR	014070	
	ACCESD	040000H		LDVCPT	014026H		PDBR2	000026H		TYPDEC	014020	
	ADCVEC	000134H		LERRPT	014022H		PDBR3	000030H		TYPDIG	014040	
	ARMCOD	060000		LFORCE	014020H		PDBR4	000032H		TYPOCT	014030	
	ARMTRP	000200H		LGETAR	014002H		PDBR5	000034H		TYPOUT	014062	
	CCNT	014446		LGETVA	014000H		PDBSP	000014H		TYPRET	014150	
	CLKCNT	172544		LHI0	015322		PDBSTA	000000H		TYPS1	014016	
	CLKS	172540		LHI1	015326		PHSPAG	003777H		TYPSTR	014000	
	CLKSET	172542		LHI2	015332		PINI0	015444		UAC0	000044H	
	CLKTRP	000104H		LHI3	015336		PINI1	015474		UADDAT	000032H	
	COM1	015354		LINTAR	014006H		PINI2	015526		UADLST	000030H	
	COM2	015376		LINVLD	014004H		PINI3	015560		UCALL	000012H	
	COM3	015414		LMOVE	014014H		PINI4	015612		UDPUSE	040000H	
	COMMON	015342		LSQRTF	014016H		PINI5	015620		UDSPCE	167036	
	COMTAB	014000		LTAB	015222		PINIT	015426		UFEA	000040H	
	CRLFX	014152		LTHPTR	014024H		PS	177776		UFEC	000036H	
	CURIN	014724		LUPDAT	014030H		PTAB0	166000		UFPS	000042H	
	DACVEC	000130H		LWHERE	014012H		PTAB1	166200		UFPSAV	020000H	
	DBS	014450		MAINBL	014726		PTAB2	166400		UFPUSE	100000H	
	DDT	130000		MAPENB	100000H		PTAB3	166600		UGR0	000022H	
	DRIVER	016270		MARK0	006400H		PTABNO	001400H		UGRSAV	004000H	
	ERRTRA	014220		MARK1	006401H		PTR	016064		UINTL	000010H	
	ERRTRP	000004H		MARK2	006402H		R0	000000R		UISPCE	167026	
	HCOR	157776		MARK3	006403H		R1	000001R		UNIBIT	004000H	
	HI0	016506		MARK4	006404H		R2	000002R		UPC	000016H	
	HI1	040000		MARK5	006405H		R3	000003R		UPCSAV	002000H	
	HI2	060000		MESF0	016562		R4	000004R		UPDLEN	000002H	
	HI3	100000		MESF1	040052		R5	000005R		UPSW	000020H	
	IBUF	000150H		MESF2	060052		RADIX	014046		USKMAX	000006H	
	II	100070H		MESF3	100044		RDPERM	010000H		USKMIN	000004H	
	ILGINS	000010H		MESI0	016540		RF	000005RH		USKP	000014H	
	IN2	014272		MESI1	040032		RUG	130000		USKSAV	010000H	
	IN3	014356		MESI2	060032		RUGMES	014155		USRORG	014000H	
	IN4	014416		MESI3	100022		SDSPCE	167032		UST0	000000H	
	INBUF	014454		MXVRPG	000176H		SISPCE	167022		VIT	171000	
	INSTR	014266		NDSPCE	167034		SP	000006R		VITTS	170777	
	INTRP	014100H		NISPCE	167024		STATR0	167000		WRINTO	100000H	
	IREG	157774		NXTEMT	104014H		STRT11	000500		WRPERM	020000H	
	JOBDAT	013774H		OBUF	000160H		SWITCH	015710		.L.	000036H	
	JOBSA	013776H		OREG	157776		SWSTCK	016266		.PDB	000000H	
	KBIR	177562		OUTBUF	014600		TEMP	016062		.W.	100000H	
	KBIS	177560		OUTSW	157772		TOSPC	015636	
	PALX 231	12/16/75  11:43:25	PAGE 49
	MAP PAL[HAL,HE]	PAGE 9 	***SYMBOL TABLE***      


1.6 WDS AVG INSN LENGTH

18 SECONDS RUN-TIME